package first.endtoend

class DashBoardController
{

    def springSecurityService

    def index()
    {
        redirect(action: "dashboard")
    }

    /*
   this action show dashboard page

    */

    def dashboard()
    {
        try
        {
            springSecurityService.currentUser as Agent
            Agent userInstance = springSecurityService.currentUser as Agent
            def fairPricesShopInstance = userInstance.fps
            def families = Family.findAllByFps(fairPricesShopInstance)
            [userInstance: userInstance, fairPricesShopInstance: fairPricesShopInstance, families: families]
        } catch (Exception e)
        {
            Admin userInstance = springSecurityService.currentUser as Admin
            [userInstance: userInstance]
        }


    }
}
